Creating Isochrones
iso_10min_walk <-
otp_isochrone(otpcon = otpcon, fromPlace = CPP_parks,
mode = "WALK", cutoffSec = 600) %>%
st_transform(crs = NC_state_plane) %>%
mutate(mode = "walk")
iso_10min_drive <-
otp_isochrone(otpcon = otpcon, fromPlace = CPP_parks,
mode = "CAR", cutoffSec = 600) %>%
st_transform(crs = NC_state_plane) %>%
mutate(mode = "drive")
iso_all_modes <- rbind(iso_10min_drive, iso_10min_walk)
otp_stop()
right_side <- st_bbox(iso_all_modes)$xmax
left_side <- st_bbox(iso_all_modes)$xmin
top_side <- st_bbox(iso_all_modes)$ymax
bottom_side <- st_bbox(iso_all_modes)$ymin
ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")

ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "cartolight", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")

ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "stamenwatercolor",
progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_discrete(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot"),
type = c("gray", "black")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")

ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "stamenbw", progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")

ggplot(iso_all_modes) +
annotation_map_tile(zoomin = 0, type = "hotstyle",
progress = "none") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_discrete(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot"),
type = c("gray", "black")) +
theme_map() +
labs(caption = "Basemap Copyright OpenStreetMap contributors")

ggplot(iso_all_modes) +
geom_sf(data = cary_streets, color = "gray") +
geom_sf(aes(fill = mode), alpha = 0.5) +
geom_sf(data = CPP_parks) +
coord_sf(xlim = c(left_side, right_side),
ylim = c(bottom_side, top_side), expand = FALSE) +
scale_fill_viridis_d(name = "Area that is reachable within 5 minutes",
labels = c("By car", "By foot")) +
theme_map()

Calcuate and compare isochrone areas
iso_areas <- iso_all_modes %>%
mutate(area = st_area(iso_all_modes)) %>%
st_set_geometry(NULL) %>%
pivot_wider(names_from = mode, values_from = area)
ggplot(iso_areas,
aes(x = as.numeric(walk), y = as.numeric(drive))) +
geom_point() +
scale_x_continuous(name =
"Area within a ten-minute walking distance\nof a public park\n(square km)",
breaks = breaks <- seq(100000, 2000000, by = 100000),
labels = breaks / 100000) +
scale_y_continuous(name =
"Area within a ten-minute driving distance\nof a public park\n(square km)",
breaks = breaks <- seq(0, 26000000, by = 2000000),
labels = breaks / 100000) +
theme_economist()
